<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<#include "/common/resources.ftl"/>
<script type="text/javascript">
	$(function(){
		$("#dds").window('close');
	
		window.m_datagrid = $('#m_datagrid').datagrid({
			url:'${ctx}/qfbao/loancommision/list',
			onLoadSuccess:yixun.closeProgress,
			onBeforeLoad:yixun.progress,
			queryParams:$('#load_list_search').serializeObject(),
			loadMsg:null,
			singleSelect:true,
			fitColumns:true,
			rownumbers:true,
			pagination:true,
			border:'false',
			toolbar:'#m_toolbar'
		});
	
		//按条件查询用户
		window.searchData = function () {
			m_datagrid.datagrid('load',$('#load_list_search').serializeObject());
		}
		
		//删除
		window.deleteDate = function(mid){
			$.messager.confirm('确认!','你确定要删除此数据吗?',function(res){
				if(res){
					$.post("${ctx}/qfbao/loancommision/del",{'id':mid},function(result){
						if (result.errorMsg){
							$.messager.show({
								title: '友情提示',
								msg: 'result.errorMsg'
							});
							m_datagrid.datagrid('reload');
						} else {
							$.messager.show({
								title: '友情提示',
								msg: '删除成功'
							});
						}
					},'json');
				}
			});
		}
		
		//确认
		window.queryDate = function(mid){
			$.messager.confirm('确认!','你确定已打款吗?',function(res){
				if(res){
					    $("#tmid").val(mid);
						var url="${ctx}/qfbao/loancommision/playMoney";
						$.ajax({
							url:url,
							 type: "POST",
							 data:{id:mid},
							 dataType:'JSON',
							 success:function(rs){
							 	$("#amount").val(rs.playMoney);
							 	$("#dds").window('open');
							 },
							
						});
					
				}
			});
		}
	});
	mShowButton = function (value,row,index){
		var btns = [];
		if(row.status=='未付款'){
			btns.push('<button class="green_btn" onclick="javascript:queryDate('+value+');void(0);">确认打款</button>');
		}
		return btns.join('');
	}
	
	function m_submit(id){
	var url="${ctx}/qfbao/loancommision/confirmationPlayMoney";
						$.ajax({
							url:url,
							 type: "POST",
							 data:{id:$("#tmid").val(),amount:$("#amount").val(),payDate:$("#payDate").datebox('getValue'),remark:$("#remark").val()},
							 dataType:'JSON',
							 success:function(rs){
							 	if(rs.success!=undefined){
							 		alert(rs.success);
							 		$("#dds").window('close');
							 		m_datagrid.datagrid('reload');
							 	}else{
							 		alert(rs.error);
							 	}
							 },
							
						});
		
	}
</script>
</head>
<body style="background-color:white;">
<input type="hidden" id="tmid">
<div id="m_toolbar" class="datagrid-toolbar" style="overflow: hidden;height: auto;margin: 15px 0px;background-color: white;border-bottom: none;" border="false">
  <form id="load_list_search" onsubmit="return false;">
  <div class="fm_sty" style="margin: 20px 0px 0px;">
   	<div class="ipt_line">
	<span class="ipt_title">未付：${weiFu}</span>
	<input type="hidden" id="orderId" name="orderId" value="<#if model?exists >${model.orderId}</#if>"></input>
	<input type="hidden" id="payerId" name="payerId" value="<#if payerId?exists >${payerId}</#if>"></input>
	</div>
   	<div class="ipt_line">
	<span class="ipt_title">应付：${yingFu}</span>
	</div>
   	<div class="ipt_line">
	<span class="ipt_title">实付：${shiFu}</span>
	</div>
	<!--<div class="ipt_line_long">
        <button class="red_100" onclick="javascript:window.location.href='viewFU?orderId=${model.orderId}&id=${model.id}';void(0)">添加应付</button>
	</div>  -->
  </div>
  </form>
</div>

<div id="dds" class="easyui-dialog" title="打款" style="width:400px;height:320px;padding:10px 20px"   
        			data-options="iconCls:'icon-save',resizable:true,modal:true" >   
        	<div class="easyui-layout" fit="true">
			<div region="center" border="false">
			<div class="ftitle">打款信息</div>
   			<div class="fitem">
				<label>打款金额:</label>
				<input id="amount" name="roleNm" class="easyui-validatebox" required="true"/>
			</div>
			<div  class="fitem">
				<label>打款日期:</label>
				<input type="text" id="payDate" style="width:180px;" class="easyui-datebox" required="required"></input>  
			</div>
			
			<div  class="fitem">
				<label>备注:</label>
				<textarea style="width:188px;height:130px;" id="remark"></textarea>
			</div>
			
   			</div>
   			</div>
   		
   		 <div region="south" border="false" style="text-align:right;height:30px;line-height:30px;">
			<a href="#" class="easyui-linkbutton" iconCls="icon-ok" plain="true" onclick="m_submit('${model.id}');">保存</a>
			
			<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" plain="true" onclick="javascript:$('#dds').window('close')">取消</a>
		</div>
      
</div>

<!-- 查找结果 -->
<table style="margin:0px 20px;" id="m_datagrid">
	<thead>
		<tr>
			<th field="orderId" width="60" height="40" >订单ID</th>
			<th field="amount" width="60" height="40" >金额</th>
			<th data-options="field:'status',formatter:function(value,row,index){var key = 'funds_status';return yixun.combobox_formatter(value,row,index,key);}" width="60" height="40" >状态</th>
			<th field="typeCN" width="60" height="40" >款类</th>
			<th field="payeeName" width="60" height="40" >收款人</th>
			<th field="confirmTime" width="60" height="40" >确认打款时间</th>
			<th data-options="field:'id',formatter:mShowButton,align:'center'" width="150">操作</th>
		</tr>
	</thead>
</table>

</body>
</html>
